from pysqlite2 import dbapi2 as sqlite
import os

class Quote:
	def __init__(self):
		self.text = None
		self.author = None
		self.origin = None
		self.tags = set()

	def addTag(self, tag):
		self.tags.add(tag)


class QuoteData:
	def __init__(self, dbfile='quotes.db'):
		self.dbfile = dbfile
		self.quotes = []
		self.authors = set()
		
		SELECT = 'select * from quotes order by text'
		not_empty = os.path.isfile('quotes.db')

		self.connection = sqlite.connect(self.dbfile)
		self.cursor = self.connection.cursor()

		if not_empty:
			self.cursor.execute(SELECT)
			quotes = self.cursor.fetchall()
			for q in quotes:
				print q

